<?php

namespace My\Controller;

use My\Controller\MyController;

/**
 * 个人中心-任务
 */
class MyTaskController extends MyController {
    
    //做过的任务-专业列表
    public function specialtyList() {
        $iCompanyId = $this->iCompanyId;
        $iRoleId = $this->iRoleId;
        if(empty($iCompanyId)){     //不属于企业，返回空
            $this->returnList();
        }
        
        $where['status'] = 1;
        if($iRoleId != 1 && $iRoleId != 2){
            $where['cate_id'] = $this->iPostId;
        }
        
        $list = M("Specialty")->field("specialty_id,specialty_name,cate_id")->where($where)->order("sort asc")->select();
        if(!empty($list)){
            foreach($list as $val){
                $arrList[$val['cate_id']][] = $val;
            }
        }
        $this->returnList($arrList);
    }

    //做过的任务-课程列表
    public function curriculumList() {
        $cate_id = $this->iPostId;
        $specialty_id = M("Specialty")->where(array('cate_id' => $cate_id))->order("sort asc")->limit(1)->getField("specialty_id");
        $specialty_id = I("specialty_id", $specialty_id, "intval"); //默认给获取第一个专业下的课程列表
        $list = M("Curriculum")->field("curriculum_id,curriculum_name,curriculum_img,description,specialty_id")->where(array('specialty_id' => $specialty_id,'status'=>1))->select();
        if (!empty($list)) {
            foreach ($list as &$val) {
                $val['curriculum_img'] = C('ADMIN_URL') . $val['curriculum_img'];
            }
            unset($val);
        }
        $this->returnList($list);
    }



}
